package com.njupt.towerinfos.controller;

import com.njupt.towerinfos.domain.Towers;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/tw")
@CrossOrigin("*")
public class TowerCtrl {
    @RequestMapping("/findTower")
    public List<Towers> findTower(int pageSize, int pageNum,
                                  @RequestParam(required = false) String towerid) {
        List<Towers> tws = new ArrayList<>();
        tws.add(Towers.builder().towerid("zt111").company("中铁").build());
        tws.add(Towers.builder().towerid("zt122").company("中铁").build());
        return tws;
    }

    @RequestMapping("/insertTower")
    public String insertTower(Towers towers){
        return "{\n" +
                "    \"towerreg\": \"success\"\n" +
                "}";
    }

    @RequestMapping("/towerMod")
    public String modTower(Towers towers) {
        return "{\n" +
                "    \"towermod\": \"success\"\n" +
                "}";
    }

    @RequestMapping("/delTower/{towerid}")
    public String del(@PathVariable("towerid") String towerid) {
        return "{\n" +
                "    \"towerdestroy\": \"success\"\n" +
                "}";
    }
}
